package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;

/**
 * Created by windo on 16/9/5.
 */
public class GetGoldCoinTask extends CouponHttpBaseTask {
    public GetGoldCoinTask() {
        super();
    }

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        JSONObject jsonObject = response.getBody();
        String coinBalance = jsonObject.getString("coinBalance");
        notifyTaskCompleted(TaskResultCode.SUCCESS,coinBalance);
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if (mPhase == TASK_PHASE_INIT){
            CouponHttpRequest request = new CouponHttpRequest();
            request.setApiNo(ApiNo.GOLD_COIN_BALANCE);
            addRequest(request);
        }
    }
}
